"""
    求矩形相交的面积
    box   = [gx1, gy1, gx2, gy2]
    boxes = [cx1, cy1, cx2, cy2]

    box   = np.array([2, 2, 20, 25])
    boxes = np.array([15, 12, 25, 21])
"""
import numpy as np

box = np.array([2, 2, 20, 25])
boxes = np.array([15, 12, 25, 21])

# a(2, 2) b(20, 25) c(15, 12) d(25, 21)
a = box[:2]
b = box[2:]
c = boxes[:2]
d = boxes[2:]
x = np.array([a[0], b[0], c[0], d[0]])
y = np.array([a[1], b[1], c[1], d[1]])
x_sort = np.sort(x)
y_sort = np.sort(y)
x_1 = x_sort[2] - x_sort[1]
y_1 = y_sort[2] - y_sort[1]
# print(x_sort)
# print(y_sort)
print(x_1*y_1)



